//
//  BKListenAnswerView.m
//  听说弱点强化训练
//
//  Created by 盛超 on 2018/9/8.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "BKListenAnswerView.h"

@implementation BKListenAnswerView {
    UILabel *_trueAnswerLabel;
    UILabel *_myAnswerLabel;
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame] ) {
        UIImageView *backImageView = [[UIImageView alloc] init];
        [self addSubview:backImageView];
        backImageView.image = [UIImage imageNamed:@"LS-参考答案背景"];
        [backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(UIEdgeInsetsMake(10, 20, 10, 20));
        }];

        UILabel *leftLabel = [[UILabel alloc] init];
        leftLabel.textColor = [UIColor colorWithHex:0x464646];
        leftLabel.textAlignment = NSTextAlignmentCenter;
        leftLabel.font = [UIFont systemFontOfSize:14];
        [backImageView addSubview:leftLabel];
        leftLabel.text = @"参考答案";
        [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(backImageView).offset(-(kWidth-40)/4);
            make.centerY.equalTo(backImageView).offset(20);
            make.size.mas_offset(CGSizeMake(60, 14));
        }];
        
        UILabel *rightLabel = [[UILabel alloc] init];
        rightLabel.textColor = [UIColor colorWithHex:0x464646];
        rightLabel.textAlignment = NSTextAlignmentCenter;
        rightLabel.font = [UIFont systemFontOfSize:14];
        [backImageView addSubview:rightLabel];
        rightLabel.text = @"我的答案";
        [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(backImageView).offset((kWidth-40)/4);
            make.centerY.equalTo(backImageView).offset(20);
            make.size.mas_offset(CGSizeMake(60, 14));
        }];
        
        UILabel *trueAnswerLabel = [[UILabel alloc] init];
        _trueAnswerLabel = trueAnswerLabel;
        trueAnswerLabel.textColor = [UIColor colorWithHex:0x0abb20];
        trueAnswerLabel.textAlignment = NSTextAlignmentCenter;
        trueAnswerLabel.font = [UIFont boldSystemFontOfSize:23];
        [backImageView addSubview:trueAnswerLabel];
        [trueAnswerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(backImageView).offset(-(kWidth-40)/4);
            make.centerY.equalTo(backImageView).offset(-10);
            make.size.mas_offset(CGSizeMake(60, 23));
        }];
        
        UILabel *myAnswerLabel = [[UILabel alloc] init];
        _myAnswerLabel = myAnswerLabel;
        myAnswerLabel.textColor = [UIColor colorWithHex:0xff2322];
        myAnswerLabel.textAlignment = NSTextAlignmentCenter;
        myAnswerLabel.font = [UIFont boldSystemFontOfSize:23];
        [backImageView addSubview:myAnswerLabel];
        [myAnswerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(backImageView).offset((kWidth-40)/4);
            make.centerY.equalTo(backImageView).offset(-10);
            make.size.mas_offset(CGSizeMake(80, 23));
        }];
        
    }
    
    return self;
}

- (void)layoutSubviews {
    _trueAnswerLabel.text = self.tureAnswer;
    if (self.myAnswer==nil || [self.myAnswer isEqualToString:@""]) {
        self.myAnswer = @"未作答";
        _myAnswerLabel.font = [UIFont boldSystemFontOfSize:20];
    }
    _myAnswerLabel.text = self.myAnswer;
    if ([self.myAnswer isEqualToString:self.tureAnswer]) {
         _myAnswerLabel.textColor = [UIColor colorWithHex:0x0abb20];
    }
}

@end
